package com.beiing.tianshuai.tianshuai.dongtai.presenter;

import com.beiing.tianshuai.tianshuai.dongtai.CallBack;
import com.beiing.tianshuai.tianshuai.dongtai.model.CommentRelayReplyModel;
import com.beiing.tianshuai.tianshuai.dongtai.model.CommentRelayReplyModelImpl;
import com.beiing.tianshuai.tianshuai.dongtai.view.CommentRelayReplyViewImpl;
import com.beiing.tianshuai.tianshuai.entity.DynamicAddReplyBean;
import com.beiing.tianshuai.tianshuai.entity.DynamicDeleteBean;
import com.beiing.tianshuai.tianshuai.entity.DynamicRelayDetailBean;

/**
 * Created by magikliu on 2017/8/25.
 */

public class CommentRelayReplyPresenter implements CommentRelayReplyPresenterImpl{

    private CommentRelayReplyViewImpl mView;
    private CommentRelayReplyModelImpl mModel;

    public CommentRelayReplyPresenter(CommentRelayReplyViewImpl mView) {
        this.mView = mView;
        this.mModel = new CommentRelayReplyModel();
    }

    @Override
    public void addReply(final String rid, String cid, final String form_uid, String to_uid, String content, String registration_id) {
        mModel.addReply(rid, cid, form_uid, to_uid, content, registration_id, new CallBack<DynamicAddReplyBean>() {

            @Override
            public void result(DynamicAddReplyBean bean) {
                getReply(rid, form_uid);
            }

            @Override
            public void error(Throwable e) {

            }
        });
    }

    @Override
    public void getReply(String id, String uid) {
        mModel.getReply(id, uid, new CallBack<DynamicRelayDetailBean>() {

            @Override
            public void result(DynamicRelayDetailBean bean) {
                mView.showReply(bean);
            }

            @Override
            public void error(Throwable e) {

            }
        });
    }

    @Override
    public void deleteReply(String uid, String id, final int position) {
        mModel.deleteReply(uid, id, new CallBack<DynamicDeleteBean>() {

            @Override
            public void result(DynamicDeleteBean bean) {
                mView.removeReply(position);
            }

            @Override
            public void error(Throwable e) {

            }
        });
    }
}
